Add Web PubSub Chat service client - #48882
yzt (Y-Sindo) wants to merge 13 commits into
Conversation
|
Azure Pipelines: Successfully started running 1 pipeline(s). 10 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
There was a problem hiding this comment.
🔵 Needs a closer look
The new authentication client has blocking package-coexistence, credential-exposure, live-test, and spec-reproducibility issues.
Pull request overview
Adds the initial preview of the Azure Web PubSub Chat service client, including authentication, synchronous/asynchronous APIs, documentation, samples, and live-test infrastructure.
Changes:
- Adds generated Chat service clients, models, paging operations, and custom token authentication.
- Adds packaging metadata, API snapshots, documentation, and samples.
- Adds unit/live tests, test resources, and CI registration.
File summaries
| File | Description |
|---|---|
.chronus/changes/webpubsub-chat-customization-2026-08-17.md |
Records the feature addition. |
eng/ignore-links.txt |
Excludes pre-publication links. |
sdk/webpubsub/ci.yml |
Registers the package artifact. |
sdk/webpubsub/tests.yml |
Uses explicit package selection. |
sdk/webpubsub/azure-messaging-webpubsubchatservice/CHANGELOG.md |
Documents the preview release. |
sdk/webpubsub/azure-messaging-webpubsubchatservice/LICENSE |
Adds licensing terms. |
sdk/webpubsub/azure-messaging-webpubsubchatservice/MANIFEST.in |
Configures source distribution contents. |
sdk/webpubsub/azure-messaging-webpubsubchatservice/README.md |
Documents setup and usage. |
sdk/webpubsub/azure-messaging-webpubsubchatservice/_metadata.json |
Records the service API version. |
sdk/webpubsub/azure-messaging-webpubsubchatservice/api.md |
Captures the public API surface. |
sdk/webpubsub/azure-messaging-webpubsubchatservice/api.metadata.yml |
Records API snapshot metadata. |
sdk/webpubsub/azure-messaging-webpubsubchatservice/apiview-properties.json |
Maps cross-language API definitions. |
sdk/webpubsub/azure-messaging-webpubsubchatservice/assets.json |
References test assets. |
sdk/webpubsub/azure-messaging-webpubsubchatservice/dev_requirements.txt |
Adds development dependencies. |
sdk/webpubsub/azure-messaging-webpubsubchatservice/package-lock.json |
Adds npm lock metadata. |
sdk/webpubsub/azure-messaging-webpubsubchatservice/pyproject.toml |
Defines package metadata and dependencies. |
sdk/webpubsub/azure-messaging-webpubsubchatservice/setup.py |
Adds setuptools packaging support. |
sdk/webpubsub/azure-messaging-webpubsubchatservice/test-resources.bicep |
Provisions live-test resources. |
sdk/webpubsub/azure-messaging-webpubsubchatservice/tests.yml |
Defines package live-test CI. |
sdk/webpubsub/azure-messaging-webpubsubchatservice/tsp-location.yaml |
Pins the generating specification. |
sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/__init__.py |
Declares the Azure namespace. |
sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/__init__.py |
Declares the messaging namespace. |
sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubservice/__init__.py |
Adds the parent package initializer. |
sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubservice/chat/__init__.py |
Exports the synchronous client. |
sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubservice/chat/_client.py |
Implements the generated sync client. |
sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubservice/chat/_configuration.py |
Configures sync policies. |
sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubservice/chat/_constants.py |
Defines built-in Chat roles. |
sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubservice/chat/_operations/__init__.py |
Initializes sync operations. |
sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubservice/chat/_operations/_operations.py |
Implements sync REST operations. |
sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubservice/chat/_operations/_patch.py |
Provides operation customization hooks. |
sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubservice/chat/_patch.py |
Customizes sync authentication and tokens. |
sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubservice/chat/_shared.py |
Adds shared authentication helpers. |
sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubservice/chat/_utils/__init__.py |
Initializes generated utilities. |
sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubservice/chat/_utils/model_base.py |
Supports generated models. |
sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubservice/chat/_utils/serialization.py |
Supports wire serialization. |
sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubservice/chat/_utils/utils.py |
Handles conditional request headers. |
sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubservice/chat/_version.py |
Defines version 1.0.0b1. |
sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubservice/chat/aio/__init__.py |
Exports the asynchronous client. |
sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubservice/chat/aio/_client.py |
Implements the generated async client. |
sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubservice/chat/aio/_configuration.py |
Configures async policies. |
sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubservice/chat/aio/_operations/__init__.py |
Initializes async operations. |
sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubservice/chat/aio/_operations/_operations.py |
Implements async REST operations. |
sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubservice/chat/aio/_operations/_patch.py |
Provides async operation hooks. |
sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubservice/chat/aio/_patch.py |
Customizes async authentication and tokens. |
sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubservice/chat/models/__init__.py |
Exports generated models. |
sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubservice/chat/models/_enums.py |
Defines permissions and user kinds. |
sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubservice/chat/models/_models.py |
Defines Chat resource models. |
sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubservice/chat/models/_patch.py |
Provides model customization hooks. |
sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubservice/chat/py.typed |
Marks typed package support. |
sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubservice/chat/types.py |
Defines JSON-compatible typed dictionaries. |
sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_tests/conftest.py |
Configures generated tests. |
sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_tests/testpreparer.py |
Prepares generated sync tests. |
sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_tests/testpreparer_async.py |
Prepares generated async tests. |
sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_tests/test_web_pub_sub_chat_service.py |
Adds generated sync operation tests. |
sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_tests/test_web_pub_sub_chat_service_async.py |
Adds generated async operation tests. |
sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/chat_message_seed.py |
Seeds messages through WebSockets. |
sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/conftest.py |
Configures test proxy behavior. |
sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_chat_message_seed.py |
Tests WebSocket seeding helpers. |
sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_client.py |
Tests synchronous custom behavior. |
sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_client_async.py |
Tests asynchronous custom behavior. |
sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_live.py |
Exercises synchronous service workflows. |
sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_live_async.py |
Exercises asynchronous service workflows. |
sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/testcase.py |
Provides shared live-test helpers. |
sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_authentication.py |
Demonstrates authentication options. |
sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_client_access.py |
Demonstrates sync client credentials. |
sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_client_access_async.py |
Demonstrates async client credentials. |
sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_message_history.py |
Demonstrates sync message history. |
sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_message_history_async.py |
Demonstrates async message history. |
sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_message_management.py |
Demonstrates message updates and deletion. |
sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_roles_and_permissions.py |
Demonstrates sync resource management. |
sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_roles_and_permissions_async.py |
Demonstrates async resource management. |
sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/chat/create_or_replace_role.py |
Generated role creation sample. |
sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/chat/create_or_replace_room.py |
Generated room creation sample. |
sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/chat/create_or_replace_room_member.py |
Generated membership creation sample. |
sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/chat/create_or_replace_user.py |
Generated user creation sample. |
sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/chat/delete_message.py |
Generated message deletion sample. |
sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/chat/delete_role.py |
Generated role deletion sample. |
sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/chat/delete_room.py |
Generated room deletion sample. |
sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/chat/delete_room_member.py |
Generated membership deletion sample. |
sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/chat/delete_user.py |
Generated user deletion sample. |
sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/chat/get_conversation.py |
Generated conversation retrieval sample. |
sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/chat/get_role.py |
Generated role retrieval sample. |
sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/chat/get_room.py |
Generated room retrieval sample. |
sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/chat/get_user.py |
Generated user retrieval sample. |
sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/chat/list_messages.py |
Generated message listing sample. |
sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/chat/list_roles.py |
Generated role listing sample. |
sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/chat/list_room_members.py |
Generated membership listing sample. |
sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/chat/update_message.py |
Generated message update sample. |
Review details
Files not reviewed (1)
- sdk/webpubsub/azure-messaging-webpubsubchatservice/package-lock.json: Generated file
- Files reviewed: 86/88 changed files
- Comments generated: 5
- Review effort level: Balanced
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
060288d to
6d547e2
Compare
There was a problem hiding this comment.
🟡 Changes recommended
Namespace compatibility, test configuration, typing, and resource-security defects must be resolved.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Review details
Files not reviewed (1)
- sdk/webpubsub/azure-messaging-webpubsubchatservice/package-lock.json: Generated file
- Files reviewed: 86/88 changed files
- Comments generated: 6
- Review effort level: Balanced
| default: | ||
| - azure-mgmt-webpubsub | ||
| - azure-messaging-webpubsubservice | ||
| - azure-messaging-webpubsubclient |
There was a problem hiding this comment.
🟡 Changes recommended
The generation pin does not reproduce the submitted API, and safe-secret live runs skip Entra token coverage.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Review details
Files not reviewed (1)
- sdk/webpubsub/azure-messaging-webpubsubchatservice/package-lock.json: Generated file
Suppressed comments (2)
sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_live_async.py:304
- Safe-secret runs disable local authentication, but the Entra-backed token request remains valid and should still be exercised. The early skip currently removes the only live coverage for that path; create and assert the key client only when local auth is enabled.
sdk/webpubsub/azure-messaging-webpubsubchatservice/tsp-location.yaml:2 - The pinned source commit predates the linked correction PR, but this generated surface already includes corrections from that PR (for example,
ChatPermission, which #44881 adds tomodels.tsp). Regenerating from this file will therefore produce a different API and discard those corrections. Please update the pin to the merged correction commit and regenerate before merging this SDK.
- Files reviewed: 89/91 changed files
- Comments generated: 1
- Review effort level: Balanced
There was a problem hiding this comment.
🔵 Needs a closer look
Client input validation is inconsistent and the JWT helper has an incorrect type annotation.
Review details
Files not reviewed (1)
- sdk/webpubsub/azure-messaging-webpubsubchatservice/package-lock.json: Generated file
Suppressed comments (3)
Previously missed (2) — in code that hasn't changed since the last review.
sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubservice/chat/_patch.py:116
- This slices the endpoint as though it is always HTTP(S), so values such as
example.comorftp://...produce malformed WebSocket URLs instead of rejecting the documented-invalid endpoint.minutes_to_expireis also validated only in the key-credential branch; token credentials send non-positive values to the service. Validate both inputs before branching so both authentication modes behave consistently.
sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubservice/chat/aio/_patch.py:113 - This async path has the same input inconsistency as the sync client: slicing assumes an HTTP(S) endpoint and silently creates a malformed WebSocket URL for any other scheme, while non-positive expiration is rejected only for key credentials. Validate both values before selecting the authentication path.
sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubservice/chat/_shared.py:62
on_requestpassesrequest.http_request.urlhere, which is a string, not anAzureKeyCredential. The incorrect annotation misdocuments the helper and causes static type checkers to flag the call.
def _encode(self, url: AzureKeyCredential) -> str:
- Files reviewed: 89/91 changed files
- Comments generated: 0 new
- Review effort level: Balanced
There was a problem hiding this comment.
🟡 Changes recommended
Endpoint validation, split-package compatibility, and an incorrect type contract must be addressed before approval.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Review details
Files not reviewed (1)
- sdk/webpubsub/azure-messaging-webpubsubchatservice/package-lock.json: Generated file
Suppressed comments (3)
Previously missed (2) — in code that hasn't changed since the last review.
sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubservice/chat/_patch.py:118
endpoint[4:]assumes an HTTP(S) prefix. Inputs such asmyservice.webpubsub.azure.comor another scheme therefore return a malformed WebSocket URL instead of the validation error provided by the existing Web PubSub client. Reject unsupported schemes before slicing the endpoint.
sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubservice/chat/aio/_patch.py:115- The async path has the same unchecked
endpoint[4:]assumption as the sync client, so a non-HTTP(S) endpoint produces an invalid access URL. Validate the scheme before deriving the WebSocket URL.
sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubservice/chat/_shared.py:62
_encodereceivesrequest.http_request.urland uses it as the JWT audience, so this parameter is a string rather than anAzureKeyCredential. The current annotation gives static analysis and maintainers an incorrect contract.
def _encode(self, url: AzureKeyCredential) -> str:
- Files reviewed: 90/92 changed files
- Comments generated: 1
- Review effort level: Balanced
yzt (Y-Sindo)
left a comment
There was a problem hiding this comment.
I found two issues in the current revision.
There was a problem hiding this comment.
🟡 Changes recommended
The nested package is incompatible with the currently published parent distribution, and both clients can generate malformed access URLs from unsupported endpoint schemes.
Get a fresh assessment by requesting another Copilot review.
Review details
Files not reviewed (1)
- sdk/webpubsub/azure-messaging-webpubsubchatservice/package-lock.json: Generated file
Suppressed comments (1)
sdk/webpubsub/azure-messaging-webpubsubservice/azure/messaging/webpubsubservice/init.py:12
- This namespace fix does not make the new package compatible with the already-published
azure-messaging-webpubsubservice1.3.0: that version's regularazure.messaging.webpubsubservicepackage does not extend its path, so it hides the siblingchatdirectory andimport azure.messaging.webpubsubservice.chatfails. The PR also leaves that distribution at version 1.3.0, so this fix cannot be published as-is. Please either move Chat out of another distribution's concrete package or version/release this parent-package change and require that new version from the Chat package.
- Files reviewed: 90/92 changed files
- Comments generated: 2
- Review effort level: Balanced (auto)
Note
Copilot is running an experiment and ran this review at Balanced.
There was a problem hiding this comment.
🟡 Changes recommended
The service-wide test pipeline omits the new package, so its live tests are not scheduled.
Get a fresh assessment by requesting another Copilot review.
Review details
Files not reviewed (1)
- sdk/webpubsub/azure-messaging-webpubsubchatservice/package-lock.json: Generated file
- Files reviewed: 88/90 changed files
- Comments generated: 1
- Review effort level: Balanced (auto)
Note
Copilot is running an experiment and ran this review at Balanced.
There was a problem hiding this comment.
🔵 Needs a closer look
Public request types require server-owned fields, expiration validation is credential-dependent, and samples log bearer-token URLs.
Review details
Files not reviewed (1)
- sdk/webpubsub/azure-messaging-webpubsubchatservice/package-lock.json: Generated file
Suppressed comments (9)
Previously missed (5) — in code that hasn't changed since the last review.
sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubchatservice/_patch.py:121
- Validate the documented lower bound before branching on credential type.
get_token_by_keycurrently raises for values below 1, but token-credential clients skip that helper and send the invalid value to the service, so the same public method has credential-dependent validation and exception behavior.
sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubchatservice/aio/_patch.py:118 - Validate the expiration before selecting the authentication path. As written, key credentials reject values below 1 locally while async token-credential clients issue a request with the invalid value, producing inconsistent behavior from this public method.
sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubchatservice/types.py:33 ChatMessageis accepted as a request-body dictionary, but this type requires the server-generatedid(and alsocreatedAt/etag). Type checkers therefore reject valid create/update payloads that contain only writable fields. Regenerate a request shape that requires only writable properties.
This issue also appears in the following locations of the same file:
- line 58
- line 80
- line 101
- line 124
sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_client_access.py:19
- This prints a bearer access token to stdout, where CI logs, terminals, or redirected output can retain it. It also contradicts the README warning not to log the returned URL. Remove the print, pass the URL directly to the intended client, and regenerate the README snippet from this sample.
sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_client_access_async.py:23 - Avoid printing the connection URL because it embeds a bearer token and can be retained in terminal or CI logs. Pass it directly to the intended client instead, consistent with the package's README security guidance.
sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubchatservice/types.py:58
- This request dictionary requires the role
name, even though the name is supplied separately as the operation's path parameter; it also requires the response-only ETag below. This makes the dictionary overload reject the valid permissions-only request body. Generate a role request shape containing only writable body fields.
sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubchatservice/types.py:80 - The room ID is supplied as a path parameter and returned by the service, but this request-body dictionary marks it required;
defaultConversationandetagare likewise response-only. This causes type checkers to reject the valid title-only room body. Generate a request type containing only writable fields.
sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubchatservice/types.py:101 - The member's user ID is already supplied in the request path, but this body dictionary requires it and also requires the response ETag. The valid role-name-only request body is therefore rejected by type checkers. Generate a request type containing only writable body fields.
sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubchatservice/types.py:124 - The user ID is supplied as the operation's path parameter, but this body dictionary requires it and the response-only ETag. As a result, type checkers reject the same valid request shape accepted by
HumanChatUser(...). Generate a request type that excludes server-owned fields.
- Files reviewed: 88/90 changed files
- Comments generated: 0 new
- Review effort level: Balanced (auto)
Note
Copilot is running an experiment and ran this review at Balanced.
There was a problem hiding this comment.
🔵 Needs a closer look
Public request TypedDicts incorrectly require server-generated fields, causing valid documented payloads to fail static type checking.
Review details
Files not reviewed (1)
- sdk/webpubsub/azure-messaging-webpubsubchatservice/package-lock.json: Generated file
Suppressed comments (5)
Previously missed (1) — in code that hasn't changed since the last review.
sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubchatservice/types.py:33
ChatMessageis accepted by theupdate_messagedictionary overload, but thisRequiredmarks the server-generated message ID as mandatory (andcreatedAt/etagbelow are likewise mandatory). Type checkers will therefore reject the supported payload shown ingenerated_samples/update_message.py, which supplies onlycreatedByandcontent. Model these response-only properties as optional in the input shape, or introduce a separate input type, then regenerate.
This issue also appears in the following locations of the same file:
- line 58
- line 80
- line 101
- line 124
sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubchatservice/types.py:58
- The dictionary overload for
create_or_replace_roleacceptsChatRole, but this makes the role name mandatory in the body even though it is supplied as therole_namepath parameter;etagis also response-only. Consequently the generated{"permissions": ...}sample is rejected by static type checking. Separate the request shape from the response shape (or correct property visibility) and regenerate.
sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubchatservice/types.py:80 create_or_replace_roomdocuments and generates a title-only dictionary request, but thisChatRoomTypedDict requires the server-populatedid,defaultConversation, andetagfields. This makes the generated sample invalid under mypy/pyright. Keep onlytitlerequired for the request shape and regenerate the public types/API snapshot.
sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubchatservice/types.py:101- The
create_or_replace_room_memberdictionary overload receivesroom_idanduser_idas path parameters, yet this input TypedDict requiresuserIdin the body and also requires the response-onlyetag. The generated sample correctly sends onlyroleName, so static type checking rejects a valid request. Define a request shape with onlyroleNamerequired and regenerate.
sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubchatservice/types.py:124 HumanChatUseris used as the dictionary request shape forcreate_or_replace_user, but it requires the path-suppliedidand response-onlyetag. The generated create-user sample omits both, so consumers following it fail static type checking. Keepkind,nickname, androleNamerequired for input while making output-only properties non-required, then regenerate.
- Files reviewed: 88/90 changed files
- Comments generated: 0 new
- Review effort level: Balanced (auto)
Note
Copilot is running an experiment and ran this review at Balanced.
There was a problem hiding this comment.
🔵 Needs a closer look
Sync and async reverse-proxy routing can fail when either endpoint contains a trailing slash.
Review details
Files not reviewed (1)
- sdk/webpubsub/azure-messaging-webpubsubchatservice/package-lock.json: Generated file
Suppressed comments (2)
Previously missed (2) — in code that hasn't changed since the last review.
sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubchatservice/_patch.py:64
- A trailing slash on either endpoint breaks reverse-proxy routing.
PipelineClientnormalizes the request URL tohttps://host/api/..., so anorigin_endpointstored ashttps://host/no longer matches inApiManagementProxy; a trailing slash on the proxy can also introduce//api/.... Normalize both endpoints before constructing the policies.
sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubchatservice/aio/_patch.py:61 - The async client has the same trailing-slash failure as the sync client: the normalized request URL may not match the stored origin, causing
reverse_proxy_endpointto be bypassed, or the replacement may create a double-slash path. Normalize both endpoint values before building the policies.
- Files reviewed: 88/90 changed files
- Comments generated: 0 new
- Review effort level: Balanced (auto)
Note
Copilot is running an experiment and ran this review at Balanced.
There was a problem hiding this comment.
🟡 Changes recommended
Request TypedDicts incorrectly require response-only fields, preventing valid dictionary payloads from passing static type checking.
Get a fresh assessment by requesting another Copilot review.
Review details
Files not reviewed (1)
- sdk/webpubsub/azure-messaging-webpubsubchatservice/package-lock.json: Generated file
Suppressed comments (3)
sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubchatservice/types.py:80
idis supplied in the operation path and is read-only onChatRoom, but this dict type requires callers to include it. This contradicts the generatedcreate_or_replace_roomsample, whose valid input contains onlytitle; regenerate a writable input shape without response-only fields.
sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubchatservice/types.py:101userIdis supplied in the operation path and is read-only on the response model, so requiring it here makes the dict overload reject the generated sample's valid{ "roleName": ... }body. Generate a request-specific shape containing only writable fields.
sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubchatservice/types.py:124idis read-only on the user response model (models/_models.py:239) but isRequiredin the dict accepted bycreate_or_replace_user. Callers already pass the ID separately asuser_id, so the dict overload cannot type-check a normal request; generate a writable user input shape instead.
- Files reviewed: 88/90 changed files
- Comments generated: 2
- Review effort level: Balanced (auto)
Note
Copilot is running an experiment and ran this review at Balanced.
| :vartype etag: str | ||
| """ | ||
|
|
||
| id: Required[str] |
There was a problem hiding this comment.
Thanks, the static-typing concern is valid. We are keeping the generated shape in this PR because the TypeSpec already marks these path/server-owned properties with @visibility(Lifecycle.Read), and the generated model constructors correctly exclude them from writable inputs. The mismatch is in the Python emitter's generated TypedDict surface, not the service contract.
This is not specific to Chat: azure-ai-contentunderstanding also accepts types.ContentAnalyzer in begin_create_analyzer, while that dictionary requires analyzerId, status, createdAt, and lastModifiedAt, all marked read-only on its model class. The relevant files are sdk/contentunderstanding/azure-ai-contentunderstanding/azure/ai/contentunderstanding/types.py and the corresponding models/_models.py and _operations/_operations.py.
Hand-editing types.py would be overwritten on regeneration; adding Chat-specific request models solely to compensate would introduce an API divergence without fixing the shared emitter behavior. We therefore prefer a shared emitter fix that respects input visibility, followed by regeneration, rather than changing the service models or generated shape in this PR.
The sync/async live tests use model instances such as ChatMessage(created_by=..., content=...), ChatRoom(title=...), and HumanChatUser(nickname=..., role_name=...). Those constructors and request serialization work without server-owned fields. Passing live tests does not resolve the dictionary typing issue: TypedDict requirements are not enforced at runtime. Model instances remain the supported typed path while this generator limitation remains.
| :vartype etag: str | ||
| """ | ||
|
|
||
| name: Required[str] |
There was a problem hiding this comment.
Agreed that a permissions-only dictionary should not need the path-supplied role name or response ETag. The same applies to the room-member dictionary. We are keeping the generated shape in this PR for the shared-emitter reasons explained in #48882 (comment).
The TypeSpec already marks ChatRole.name, ChatRoomMember.userId, and the ETag fields as read-only. The generated model constructors correctly accept ChatRole(permissions=...) and ChatRoomMember(role_name=...), with the resource identifiers supplied separately as operation arguments; our live tests exercise those paths.
The remaining limitation is specifically the generated dictionary annotations. We prefer to address input visibility in the Python emitter and regenerate consistently across SDKs, rather than hand-edit generated types or introduce package-specific request models to work around it. This keeps generation reproducible and preserves the existing model-based API, while acknowledging that writable-only dictionaries still encounter static type-checking errors.
Description
Add an initial version of Web PubSub Chat service client.
Generated from Spec
All SDK Contribution checklist:
General Guidelines and Best Practices
Testing Guidelines